﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WI_E2_Parser
{
    class DomainName
    {
        public int domainName = 0;
        public int timeStamp = 0;
        public double crawlerDelay = 1;

        public List<string> restrictions;
        List<string> allowend;

        public DomainName(string DM)
        {
            Robots r = new Robots(DM + "/robots.txt");
            domainName = DM.GetHashCode();
            restrictions = r.disallowedList;
            allowend = r.allowedList;
            crawlerDelay = r.crawlDelay;
        }

        public void updateTimeStamp()
        {
            timeStamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
        }

        public bool allowedToVisit()
        {
            return ((Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds - timeStamp) > crawlerDelay;
        }


    }
}
